Feat: 웹소켓 이벤트 기반으로 스터디룸 멤버 동기화 개선 (#289) #294
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📌 개요
스터디룸 내 사용자의 입장 및 퇴장 상태를 실시간으로 클라이언트에 반영하기 위한 이벤트 기반 시스템을 도입하고, 이 과정에서 발생한 순환 참조 문제를 해결하여 백엔드 아키텍처를 개선했습니다.
🔨 작업 내용
실시간 입/퇴장 이벤트 방송 기능 추가
/topic/room/{roomId}/events로 방송됩니다./topic/room/{roomId}/events로 방송됩니다.순환 참조 문제 해결을 위한 아키텍처 리팩토링
WebSocketSessionManager와RoomParticipantService간의 양방향 의존성으로 인해 순환 참조가 발생하여 애플리케이션 실행에 실패했습니다.ApplicationEventPublisher를 활용한 발행/구독 모델을 도입하여 두 서비스 간의 직접적인 결합을 끊어냈습니다.개선된 서비스 역할 분담
WebSocketSessionManager: 이제 세션 종료 시RoomParticipantService를 직접 호출하는 대신,SessionDisconnectedEvent를 발행하는 책임만 가집니다.RoomParticipantService: 발행된SessionDisconnectedEvent를 구독(@EventListener)하여, 세션이 종료된 사용자에 대한 퇴장 처리 로직을 스스로 수행합니다.🔗 관련 이슈
Closes #289
📝 참고 사항
WebSocketSessionManagerTest는 이제 이벤트 발행 여부만 검증하고,RoomParticipantServiceTest는 이벤트 수신 시 퇴장 로직이 정상 동작하는지를 검증하도록 테스트 코드를 수정했습니다.✅ 체크리스트